/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.pay.view;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.ScrollView;
import android.widget.TextView;
import com.qihoo.gamecenter.sdk.common.i.s;
import com.qihoo.gamecenter.sdk.pay.f.a;
import com.qihoo.gamecenter.sdk.pay.k.d;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class PayTypeView extends LinearLayout {
    private Context b;
    protected View a;
    private LinearLayout c;
    private String d;
    private List e;
    private com.qihoo.gamecenter.sdk.pay.res.b f;
    private a g;
    private a h;

    private PayTypeView(Context paramContext) {
        super(paramContext);
        this.e = new ArrayList();
        this.h = new a(null);
    }

    public PayTypeView(Intent paramIntent, Context paramContext) {
        this(paramContext);
        this.b = paramContext;
        this.f = com.qihoo.gamecenter.sdk.pay.res.b.a(paramContext);
        this.d = paramIntent.getStringExtra("pay_type_default");
        String[] arrayOfString = paramIntent.getStringArrayExtra("pay_type_definition");
        if (arrayOfString != null) {
            this.e.clear();
            for (int i = 0; i < arrayOfString.length; ++i)
                this.e.add(arrayOfString[i]);
            if (this.e.contains("MOBILE_CARD"))
                this.e.add("360bi");
            com.qihoo.gamecenter.sdk.pay.k.c.a("PayTypeView",
                    new Object[] { "User defined pay type -- > ", Arrays.toString(arrayOfString) });
        }
        b();
    }

    private void b() {
        LinearLayout.LayoutParams localLayoutParams = new LinearLayout.LayoutParams(-1, -1);
        setLayoutParams(localLayoutParams);
        ScrollView localScrollView = new ScrollView(this.b);
        localScrollView.setLayoutParams(localLayoutParams);
        localScrollView.setVerticalScrollBarEnabled(true);
        localScrollView.setVerticalFadingEdgeEnabled(false);
        addView(localScrollView);
        this.c = new LinearLayout(this.b);
        this.c.setLayoutParams(localLayoutParams);
        this.c.setOrientation(1);
        this.c.setGravity(17);
        localScrollView.addView(this.c);
    }

    public void a() {
        a(this.a);
    }

    public void setPayTypeItemChangesCallBack(a parama) {
        this.g = parama;
    }

    public void a(List paramList) {
        this.c.removeAllViews();
        LinearLayout.LayoutParams localLayoutParams = new LinearLayout.LayoutParams(-1, s.b(this.b, 41.0F));
        if ((paramList == null) || (paramList.isEmpty()))
            return;
        String str1 = d.c(this.b);
        Object localObject = null;
        View localView = null;
        this.a = null;
        int i = -1;
        Iterator localIterator = paramList.iterator();
        while (localIterator.hasNext()) {
            com.qihoo.gamecenter.sdk.pay.c localc = (com.qihoo.gamecenter.sdk.pay.c) localIterator.next();
            if (localc == null)
                continue;
            com.qihoo.gamecenter.sdk.pay.k.c.a("PayTypeView", new Object[] { "Pay Type => ", localc.d() });
            String str2 = localc.d();
            if ((!(this.e.isEmpty())) && (!(this.e.contains(str2))))
                continue;
            localView = a(localc, localLayoutParams);
            this.c.addView(localView);
            if (str2.equalsIgnoreCase(str1))
                localObject = localView;
            else if ((localObject == null) && (str2.equalsIgnoreCase(this.d)))
                localObject = localView;
            else if ("BANK_QUICKPAY".equalsIgnoreCase(str2))
                i = this.c.getChildCount() - 1;
        }
        if ((localObject == null) && (i != -1))
            localObject = this.c.getChildAt(i);
        if ((localObject == null) && (this.c.getChildCount() > 0))
            localObject = this.c.getChildAt(0);
        this.a = ((View) localObject);
        localView = null;
        localObject = null;
    }

    private View a(com.qihoo.gamecenter.sdk.pay.c paramc, LinearLayout.LayoutParams paramLayoutParams) {
        RelativeLayout localRelativeLayout = new RelativeLayout(this.b);
        localRelativeLayout.setLayoutParams(paramLayoutParams);
        localRelativeLayout.setOnClickListener(this.h);
        localRelativeLayout.setTag(paramc);
        RelativeLayout.LayoutParams localLayoutParams1 = new RelativeLayout.LayoutParams(-2, -1);
        localLayoutParams1.addRule(13, -1);
        TextView localTextView = new TextView(this.b);
        localTextView.setId(com.qihoo.gamecenter.sdk.pay.b.y.ordinal());
        localTextView.setText(paramc.e());
        localTextView.setLayoutParams(localLayoutParams1);
        localTextView.setTextColor(-6401536);
        localTextView.setTextSize(1, s.a(this.b, 13.3F));
        localTextView.setGravity(16);
        localTextView.setPadding(0, 0, s.b(this.b, 16.0F), 0);
        localRelativeLayout.addView(localTextView);
        if ("BANK_QUICKPAY".equalsIgnoreCase(paramc.d())) {
            RelativeLayout.LayoutParams localLayoutParams2 = new RelativeLayout.LayoutParams(s.b(this.b, 16.0F), s.b(
                    this.b, 16.0F));
            localLayoutParams2.addRule(6, com.qihoo.gamecenter.sdk.pay.b.y.ordinal());
            localLayoutParams2.addRule(7, com.qihoo.gamecenter.sdk.pay.b.y.ordinal());
            localLayoutParams2.topMargin = s.b(this.b, 8.0F);
            ImageView localImageView = new ImageView(this.b);
            localImageView.setLayoutParams(localLayoutParams2);
            localImageView.setScaleType(ImageView.ScaleType.FIT_XY);
            localImageView.setImageDrawable(this.f.a(1073741900));
            localRelativeLayout.addView(localImageView);
        }
        return localRelativeLayout;
    }

    private void a(View paramView) {
        if (paramView == null)
            return;
        a(this.a, false);
        this.a = paramView;
        a(this.a, true);
        com.qihoo.gamecenter.sdk.pay.c localc = (com.qihoo.gamecenter.sdk.pay.c) this.a.getTag();
        com.qihoo.gamecenter.sdk.pay.k.c.a("PayTypeView", new Object[] { "Selected Pay Type --->", localc.e() });
        if (this.g == null)
            return;
        this.g.a(localc);
    }

    private void a(View paramView, boolean paramBoolean) {
        if (paramView == null)
            return;
        TextView localTextView = (TextView) paramView.findViewById(com.qihoo.gamecenter.sdk.pay.b.y.ordinal());
        if (paramBoolean) {
            this.f.a(paramView, -1073741770);
            localTextView.setTextColor(-1);
        }
        else {
            paramView.setBackgroundColor(16777215);
            localTextView.setTextColor(-6401536);
        }
    }

    private class a implements View.OnClickListener {
        public void onClick(View paramView) {
            if (paramView == PayTypeView.this.a)
                return;
            PayTypeView.a(PayTypeView.this, paramView);
        }
    }
}